    <template>
    <el-form :model="forma" ref="forma" :rules="formaRules" label-position="right" label-width="10rem" class="form-width-medium">
        <el-form-item label="溯源模式">
            <el-switch v-model="forma.retrospect_model" active-text="开启" inactive-text="关闭" />
        </el-form-item>
<!--        <el-form-item>-->
<!--            <el-button @click="eventClickSubmitOperate" :loading="options.loading">保存</el-button>-->
<!--        </el-form-item>-->
    </el-form>
</template>

<script>
    import {
        Form, FormItem, Input, Button, Message, Select, Option,
        Switch
    } from 'element-ui';

    export default {
        components: {
            [Form.name]: Form, [FormItem.name]: FormItem, [Input.name]: Input, [Button.name]: Button,
            [Select.name]: Select, [Option.name]: Option, [Switch.name]: Switch
        },
        data () {
            return {
                options: {
                    loading: false
                },
                forma: {
                    retrospect_model: "",
                    data:[],
                    traceToSource: false
                },
                formaRules: {
                    nickName: [
                        { required: true, message: '请输入用户的昵称', trigger: 'blur' }
                    ],
                    mobile: [
                        { required: true, message: '请输入用户的电话', trigger: 'blur' }
                    ],
                    name: [
                        { required: true, message: '请输入暂存点名称', trigger: 'blur' }
                    ],
                    address: [
                        { required: true, message: '请输入暂存点位置', trigger: 'blur' }
                    ]
                }
            }
        },
        mounted () {
            this.eventClickSubmitOperate();
        },
        methods: {
            eventClickSubmitOperate() {
                this.options.loading = true;
                this.$refs['forma'].validate((valid) => {
                    if(valid) {
                        let url = '/api/admin/System/getlist',
                            params = {};
                        this.$util.postRequestInterface(url, params, (res) => {
                            this.options.loading = false;
                            this.forma.retrospect_model=res.data[57].value==1?true:false;
                            this.forma.data.retrospect_model=res.data[57].value==1?true:false;
                        });
                    } else {
                        this.options.loading = false;
                    }
                });
            }
        },
        watch: {
            'forma.retrospect_model'(nVal, oVal) {
                if(this.forma.data.retrospect_model!=nVal){
                    this.options.loading = true;
                    let url = '/api/admin/System/changeone';
                    let params = {value:nVal==true?1:0,name:'retrospect_model'};
                    this.$util.postRequestInterface(url, params, {
                        success: (res) => {
                            Message.success("配置修改成功");
                            this.forma.data.retrospect_model=nVal;
                        },
                        complete: (res) => {
                            this.options.loading = false;
                        }
                    });
                }
            }
        }
    }
</script>

<style lang="scss" scoped>
</style>
